package org.test;

import java.lang.reflect.Method;
import java.time.Year;
import java.util.Scanner;
import java.util.logging.Logger;

public class MainTest05 {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入年份");
        boolean flag = true;
        long year = 0;
        while (flag){
            try{
                year = scanner.nextLong();
                flag = false;
            }catch (Exception e){
                System.out.println("请输入正确的年份");
            }
        }
        Class<Year> yearClass = Year.class;
        Method isLeap = yearClass.getMethod("isLeap", long.class);
        boolean invoke = (boolean) isLeap.invoke(null, year);
        System.out.println(year + "年是" + (invoke ? "闰年" : "平年"));
    }
}
